//
//  HappyBabyController.m
//  HappyBaby
//
//  Created by 华哥 on 15/11/23.
//  Copyright © 2015年 华哥. All rights reserved.
//

#import "HappyBabyController.h"

@interface HappyBabyController ()

@end

@implementation HappyBabyController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:99/255.0 green:157/255.0 blue:236/255.0 alpha:1]];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //     创建返回按钮
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(0, 0, 25, 25);
    [backButton setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    // 添加返回方法
    [backButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *back = [[UIBarButtonItem alloc]initWithCustomView:backButton];
    //     怎么添加到每一个控制器上;
    viewController.navigationItem.leftBarButtonItem = back;
    
    // 添加rightBarButtonItem, 是有两种状态
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0, 0, 25, 25);
    [rightButton setImage:[UIImage imageNamed:@"shut"] forState:UIControlStateNormal];
    [rightButton setImage:[UIImage imageNamed:@"look"] forState:UIControlStateSelected];
    
    UIBarButtonItem *rightBarbutton = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    viewController.navigationItem.rightBarButtonItem = rightBarbutton;
    
    // super一定要写, 不然就失去push功能;
    [super pushViewController:viewController animated:animated];
}

- (void)back:(UIButton *)button
{
    [self popViewControllerAnimated:YES];
}


@end
